From d9f1620b2fe46d90097dbbe96a867ac480d4408e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Timm=20B=C3=A4der?= Date: Tue, 12 Dec 2017 20:33:53 +0100 Subject: [PATCH] snapshot: Directly clip color nodes Clipping a color node is trivial so we do it here directly since that might later save the entire clip node as well as freeing the fragment shaders from coloring lots of pixels that will be clipped away. --- gtk/gtksnapshot.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c index d632ef6364..c3f9295045 100644 --- a/gtk/gtksnapshot.c +++ b/gtk/gtksnapshot.c @@ -1345,7 +1345,23 @@ gtk_snapshot_append_color (GtkSnapshot *snapshot, g_return_if_fail (color != NULL); g_return_if_fail (bounds != NULL); + graphene_rect_offset_r (bounds, current_state->translate_x, current_state->translate_y, &real_bounds); + + /* Color nodes are trivially "clippable" so we do it now */ + if (current_state->clip_region) + { + cairo_rectangle_int_t clip_extents; + cairo_region_get_extents (current_state->clip_region, &clip_extents); + graphene_rect_intersection (&GRAPHENE_RECT_INIT ( + clip_extents.x, + clip_extents.y, + clip_extents.width, + clip_extents.height + ), + &real_bounds, &real_bounds); + } + node = gsk_color_node_new (color, &real_bounds); if (name && snapshot->record_names) -- 2.30.2